package la.iok.hzsvn.lewin.movie.operation.controller;

import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.lewin.movie.operation.model.SupportReturnMoneyShopParam;
import la.iok.hzsvn.lewin.movie.operation.model.SupportReturnMoneyShopVo;
import la.iok.hzsvn.lewin.movie.operation.service.SupportReturnMoneyShopService;
import la.iok.hzsvn.lewin.mybatis.model.PageParam;
import la.iok.hzsvn.lewin.mybatis.model.PageVo;
import la.iok.hzsvn.lewin.mybatis.model.SortParam;
import la.iok.hzsvn.share.response.OperatorResponse;
import la.iok.hzsvn.share.response.OperatorResponses;
import la.iok.hzsvn.share.response.SingleDataResponse;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("supportReturnMoneyShop")
public class SupportReturnMoneyShopController {
    private final SupportReturnMoneyShopService supportReturnMoneyShopService;

    public SupportReturnMoneyShopController(SupportReturnMoneyShopService supportReturnMoneyShopService) {
        this.supportReturnMoneyShopService = supportReturnMoneyShopService;
    }

    @PostMapping
    public OperatorResponse save(@RequestHeader Token token, @RequestBody SupportReturnMoneyShopParam param){
        supportReturnMoneyShopService.save(token, param.getOrgUnitId());
        return OperatorResponses.success();
    }

    @DeleteMapping("{id}")
    public OperatorResponse delete(@RequestHeader Token token,@PathVariable Long id){
        supportReturnMoneyShopService.delete(token,id);
        return OperatorResponses.success();
    }

    @GetMapping
    public SingleDataResponse<PageVo<SupportReturnMoneyShopVo>> page(@RequestHeader Token token, PageParam pageParam, SortParam sortParam, SupportReturnMoneyShopParam listParam){
        return new SingleDataResponse<>(supportReturnMoneyShopService.page(token, pageParam, sortParam, listParam));
    }
}
